package com.zhuoli.service.springboot.mybatis.config.repository.mapper;

import com.zhuoli.service.springboot.mybatis.config.repository.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: zhuoli
 * @Date: 2018/8/5 13:35
 * @Description:
 */
@Mapper
public interface UserMapper {
    @Select("SELECT * FROM user WHERE id = #{id}")
    List<User> findById(@Param("id") Long id);

    @Select("SELECT * FROM user")
    List<User> getAllUsers();

    int createUser(User user);

    @Insert("INSERT INTO user(user_name,description, is_deleted) VALUES (#{userName},#{description},0)")
    int createUseByAnnotation(User user);

    /*软删除*/
    @Update("UPDATE user SET is_deleted = 1 WHERE id = #{id}")
    int deleteUserById(@Param("id") Long id);

    /*彻底删除*/
    @Delete("DELETE from user WHERE id = #{id}")
    int deleteUserComplete(@Param("id") Long id);

    int updateUser(User user);
}
